The widgetBackground
modifier is used to define background styles specifically for widgets, with behavior optimized for iOS 18’s accented (tinted) rendering mode.
In accented mode, iOS displays nearly all view colors—including backgrounds—as white, unless the view is explicitly marked with widgetAccentable
. This can cause unintended visual issues in widgets.
The widgetBackground
modifier addresses this by:
This ensures your widget layout remains visually consistent and unaffected by system-imposed tinting rules.
The widgetBackground
modifier accepts several input formats:
Apply a simple color to the background.
Apply different styles for light and dark modes.
Use a shape along with a fill style. This form provides structured and stylized backgrounds.
You may use any supported built-in or custom shape types, such as:
'rect'
, 'circle'
, 'capsule'
, 'ellipse'
, 'buttonBorder'
, 'containerRelative'
cornerRadius
, cornerSize
, or cornerRadii
This conditional behavior ensures better design control and visual integrity across widget contexts.
widgetBackground
only in widget-specific views.widgetAccentable
to precisely control which parts of the widget are subject to system tinting.